#ifndef MLOADER_ANIMATION
#define MLOADER_ANIMATION

#include "Common.h"

namespace MLoader
{
    // Effect Node/Bone
    struct ANodeKeyFrame
    {
        double Time;             // Time of this key
        gm::Transform Transform; //
    };
    struct AnimationNode
    {
        typedef enum AnimBehaviour
        {
            AnimBehaviourDefault  = 0x0,
            AnimBehaviourConstant = 0x1,
            AnimBehaviourLinear   = 0x2,
            AnimBehaviourRepeat   = 0x3,
        } AnimBehaviour;
        
        std::string Name;
        
        AnimBehaviour PosePre;
        AnimBehaviour PosePost;
        std::vector<ANodeKeyFrame> KeyFrames;
    };

    // Effect Mesh only
    struct AMeshKeyFrame
    {
        double Time;  // Time of this key
        size_t Index; // Index into the Animation's key frames
        
        bool operator == (const AMeshKeyFrame& o) const
        {
            return o.Index == Index;
        }
        
        bool operator < (const AMeshKeyFrame& o) const
        {
            return Time < o.Time;
        }
    };
    struct AnimationMesh
    {
        std::string Name;
        std::vector<AMeshKeyFrame> KeyFrames;
    };

    class Animation
    {
    public:
        std::string Name;
        double Duration;       // Duration of the animation in ticks
        double TicksPerSecond; // 0 if not specified
        
        // Channels Count means animation's pose count
        std::vector<AnimationNode> NodeChannels; // Each channel affects a single Node
        std::vector<AnimationMesh> MeshChannels; // Each channel affects a single Mesh
    };
}


#endif // MLOADER_ANIMATION
